Technotes


VCBs and Drive Numbers : The Real Story



Technote FL 34January 1987



Revised by: March 1988
Written by: Rick Blair January 1987

The top of page IV-178 in The File Manager chapter of Inside Macintosh in attempts to explain the behavior of two fields in a volume control block when the corresponding disk is offline or ejected. Due to the fact that a little bit is left unsaid, this paragraph is rather misleading. The two fields in question are vcbDrvNum and vcbDRefNum (referred to as ioVDrvInfo and ioVDRefNum in C and Pascal). PBHGetVInfo can be used to access these fields.


Offline

When a mounted volume is placed offline, vcbDrvNum is cleared and vcbDRefNum is set to the two's complement of the drive number. Since drive numbers are assigned positive values (starting with one), this will be a negative number. If vcbDrvNum is zero and vcbDRefNum is negative, you know that the volume is offline.

Ejected

When a volume is ejected, vcbDrvNum is cleared and vcbDRefNum is set to the positive drive number. If vcbDrvNum is zero and vcbDRefNum is positive, you know that the volume is ejected. Ejection implies being offline. There is no such thing as "premature ejection".

Summary

online offline ejected

vcbDrvNum			>0 (DrvNum)		0			0
vcbDRefNum			<0 (DRefNum)		<0 (-DrvNum)		>0 (DrvNum)

Please refrain from assuming anything about a VCB queue element beyond what is documented in Inside Macintosh, and don't expect it to always be 178 bytes in size. It grew when we went from MFS to HFS, and it may grow again. It's safest to use calls like PBHGetVInfo to get the information that you need.

Further Reference:




Technotes
Previous Technote | Contents | Next Technote